//
//  HomeSectionHeaderView.m
//  LvXi_newVersion
//
//  Created by 王敏 on 16/8/12.
//  Copyright © 2016年 SJT. All rights reserved.
//

#import "HomeSectionHeaderView.h"

@interface HomeSectionHeaderView()

@property(nonatomic,strong)UIView * leftLine;
@property(nonatomic,strong)UIView * rightLine;

@end

@implementation HomeSectionHeaderView
-(id)initWithFrame:(CGRect)frame{
    if(self = [super initWithFrame:frame]){
        
        self.backgroundColor = [UIColor whiteColor];
        UIView * colorBlock = [[UIView alloc] initWithFrame:CGRectMake(Ratio_Home_Width(11), 0, Ratio_Home_Width(5), self.height)];
//        [self addSubview:colorBlock];
        colorBlock.backgroundColor = HexColor(@"#FF9E05");
        [colorBlock addRadius:2];
        
        
        UILabel * titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(colorBlock.right+Ratio_Home_Width(18.f), 0, ScreenWidth - colorBlock.right - Ratio_Home_Width(18.f), self.height)];
        titleLabel.font = [UIFont systemFontOfSize:ISBigScreen?14:12];
        [self addSubview:titleLabel];
        self.titleLabel = titleLabel;
        
//        if(ISBigScreen){
//            colorBlock.hidden = YES;
//            titleLabel.centerX = ScreenWidth * 0.5;
//            titleLabel.textAlignment = NSTextAlignmentCenter;
//        }
//        else{
//            
//        }
        
        self.leftLine = [[UIView alloc] initWithFrame:CGRectMake(0, self.height* 0.5-1, 0, 2)];
        self.leftLine.backgroundColor = HexColor(@"#3CB034");
        [self addSubview:self.leftLine];
        
        self.rightLine = [[UIView alloc] initWithFrame:CGRectMake(0, self.height* 0.5-1, 0, 2)];
        self.rightLine.backgroundColor = HexColor(@"#3CB034");
        [self addSubview:self.rightLine];
    }
    return self;
}


-(void)layoutSubviews{
    [super layoutSubviews];
    self.titleLabel.size = [self.titleLabel.text sizeInAre:MaxSize font:self.titleLabel.font];
    self.titleLabel.x = self.width * 0.5 - self.titleLabel.width * 0.5;
    self.titleLabel.y = self.height * 0.5 - self.titleLabel.height * 0.5;
    
    
    self.leftLine.x = 6*globalMargin;
    self.leftLine.width = (self.width - self.titleLabel.width - 16*globalMargin)/2.0;
    
    self.rightLine.x = self.width - 6*globalMargin - self.leftLine.width;
    self.rightLine.width = (self.width - self.titleLabel.width - 16*globalMargin)/2.0;
}

@end
